/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jugueteria_lm;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Gorda
 */
public class Ventas extends javax.swing.JFrame {

   Jugueteria_Datos obj = new Jugueteria_Datos();
    Conexion conectar = new Conexion();
    public Ventas() {
        initComponents();
        MostrarVentas("");
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPDevol = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        Tabla_ventas = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        TablaVista = new javax.swing.JTable();
        ven3 = new javax.swing.JTextField();
        ven1 = new javax.swing.JTextField();
        ven4 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jTBusca = new javax.swing.JTextField();
        jButton6 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        ven2 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        ven5 = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        ven6 = new javax.swing.JTextField();
        ven7 = new javax.swing.JTextField();
        jButton13 = new javax.swing.JButton();
        jComboBox1 = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPDevol.setBackground(new java.awt.Color(0, 255, 255));

        Tabla_ventas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(Tabla_ventas);

        TablaVista.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane2.setViewportView(TablaVista);

        ven3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ven3ActionPerformed(evt);
            }
        });

        ven1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ven1ActionPerformed(evt);
            }
        });

        jLabel1.setText("Fecha");

        jLabel2.setText("Total");

        jLabel3.setText("ID venta");

        jButton2.setText("Nuevo");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Agregar");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("Actualizar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setText("Buscar");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setText("Modificar");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jLabel4.setText("Cantidad juguete");

        jLabel10.setText("Juguete");

        jLabel11.setText("Cliente");

        jLabel12.setText("Empleado");

        jButton13.setText("Mostrar");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SeleccioneTabla", "Juguete", "Cliente", "Empleado" }));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jButton1.setText("Eliminar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton7.setBackground(new java.awt.Color(204, 0, 0));
        jButton7.setText("Salir");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPDevolLayout = new javax.swing.GroupLayout(jPDevol);
        jPDevol.setLayout(jPDevolLayout);
        jPDevolLayout.setHorizontalGroup(
            jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPDevolLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPDevolLayout.createSequentialGroup()
                        .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton4)
                            .addComponent(jButton2))
                        .addGap(37, 37, 37)
                        .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton6)
                            .addComponent(jButton3))
                        .addGap(31, 31, 31)
                        .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPDevolLayout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addComponent(ven1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(11, 11, 11)
                        .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addGroup(jPDevolLayout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(ven2, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(ven3, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ven4, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(ven5)
                            .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ven6, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12))
                        .addGap(18, 18, 18)
                        .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(ven7)
                            .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPDevolLayout.createSequentialGroup()
                        .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPDevolLayout.createSequentialGroup()
                                .addComponent(jButton5)
                                .addGap(26, 26, 26)
                                .addComponent(jTBusca, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPDevolLayout.createSequentialGroup()
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 599, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButton13)
                                    .addComponent(jButton1)))
                            .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPDevolLayout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 743, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(17, Short.MAX_VALUE))))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPDevolLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(67, 67, 67))
        );
        jPDevolLayout.setVerticalGroup(
            jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPDevolLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPDevolLayout.createSequentialGroup()
                        .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPDevolLayout.createSequentialGroup()
                                .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jButton2)
                                    .addComponent(jButton3))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton6)))
                            .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPDevolLayout.createSequentialGroup()
                                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(ven1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(ven2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addComponent(jLabel4)
                                .addGroup(jPDevolLayout.createSequentialGroup()
                                    .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel1)
                                        .addComponent(jLabel2))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(ven4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(ven3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(jPDevolLayout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(ven5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(13, 13, 13))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPDevolLayout.createSequentialGroup()
                        .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPDevolLayout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(ven6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPDevolLayout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(ven7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPDevolLayout.createSequentialGroup()
                        .addComponent(jButton13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPDevolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton5)
                    .addComponent(jTBusca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton7)
                .addGap(1803, 1803, 1803))
        );

        getContentPane().add(jPDevol, new org.netbeans.lib.awtextra.AbsoluteConstraints(1, 2, 770, 620));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ven3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ven3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ven3ActionPerformed

    private void ven1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ven1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ven1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        ven3.setText(null);
        ven4.setText(null);
        ven1.setText(null);
        ven2.setText(null);
        ven5.setText(null);
        ven6.setText(null);
        ven7.setText(null);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        
        try {
            try (PreparedStatement insertar = conectar.getConnection().prepareStatement("insert into ventas(idventas, cant_juguetes, total, fecha, juguete, empleado,clientenick) "
                + " values(?,?,?,?,?,?,?)")) {
            insertar.setString(1, ven1.getText());
            insertar.setString(2, ven2.getText());
            insertar.setString(3, ven3.getText());
            insertar.setString(4, ven4.getText());
            insertar.setString(5, ven5.getText());
            insertar.setString(6, ven6.getText());
            insertar.setString(7, ven7.getText());
            insertar.execute();
            insertar.close();
            JOptionPane.showMessageDialog(null, "cliente Agregado");
            MostrarVentas("");
        }
        } catch (SQLException e) {
            System.out.print(e.getMessage());
            
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here://ventas

        try {

            PreparedStatement pre = conectar.getConnection().prepareStatement("UPDATE ventas "
                + "SET cant_juguetes='" + ven2.getText() + "', total='" + ven3.getText() + "', fecha='" + ven4.getText()+"', juguete='"+ ven5.getText()
                + "', empleado='"+ ven6.getText()+ "', clientenick='"+ ven7.getText()+"' WHERE idventas='" + ven1.getText() + "';");
            pre.executeUpdate();

            JOptionPane.showMessageDialog(this, "Se Actualizo con exito");
            MostrarVentas("");
        } catch (SQLException ex) {
            //JOptionPane.showMessageDialog(this, "Error al Corregir");
            System.out.print(ex.getMessage());
        }
    }//GEN-LAST:event_jButton4ActionPerformed

    
     
    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:

        MostrarVentas(jTBusca.getText());
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        int fila2 = Tabla_ventas.getSelectedRow();
        if (fila2 >= 0) {
            ven1.setText(Tabla_ventas.getValueAt(fila2, 0).toString());
            ven2.setText(Tabla_ventas.getValueAt(fila2, 1).toString());
            ven3.setText(Tabla_ventas.getValueAt(fila2, 2).toString());
            ven4.setText(Tabla_ventas.getValueAt(fila2, 3).toString());
            ven5.setText(Tabla_ventas.getValueAt(fila2, 4).toString());
            ven6.setText(Tabla_ventas.getValueAt(fila2, 5).toString());
            ven7.setText(Tabla_ventas.getValueAt(fila2, 6).toString());

        } else {
            JOptionPane.showMessageDialog(null, "Seleccionado una fila por favor");

        }
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
        // TODO add your handling code here:
        MostrarVentas("");
    }//GEN-LAST:event_jButton13ActionPerformed

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        // TODO add your handling code here:
        /*SeleccioneTabla
Juguete
Cliente
Empleado*/ String Tabla= jComboBox1.getSelectedItem().toString();
       String Seleccion= "SeleccioneTabla";
       if (Tabla != Seleccion){
       if(Tabla.equals("Cliente")){
           
           MostrarCliente("");
           }else if(Tabla.equals("Juguete")){
           MostrarJuguete("");
           }else if(Tabla.equals("Empleado")){
           MostrarEmpleado("");
           }
       }
    }//GEN-LAST:event_jComboBox1ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        int fild = Tabla_ventas.getSelectedRow();
        if (fild > -1) {
            String id = String.valueOf(Tabla_ventas.getValueAt(fild, 0));
            obj.Elimina_Datos("ventas", "idventas", id);
            MostrarVentas("");
            fild = -1;
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
         this.setVisible(false);
    }//GEN-LAST:event_jButton7ActionPerformed
 void MostrarEmpleado(String empleado) {
        DefaultTableModel ModeloEmpleado = new DefaultTableModel();

        ModeloEmpleado.addColumn("ID Empleado");
        ModeloEmpleado.addColumn(" Nombre");
        ModeloEmpleado.addColumn("Telefono");
        ModeloEmpleado.addColumn("Sueldo");
        ModeloEmpleado.addColumn("Cargo");

        TablaVista.setModel(ModeloEmpleado);
        String sql = "";
        if (empleado.equals("")) {

            sql = "SELECT * FROM empleado";
        } else {
            sql = "SELECT * FROM empleado WHERE idempleado ='" + empleado + "'";
        }
        String[] datosemp = new String[5];
        try {
            Statement st = conectar.getConnection().createStatement();
            ResultSet rs = st.executeQuery(sql);
            while (rs.next()) {
                datosemp[0] = rs.getString(1);
                datosemp[1] = rs.getString(2);
                datosemp[2] = rs.getString(3);
                datosemp[3] = rs.getString(4);
                datosemp[4] = rs.getString(5);

                ModeloEmpleado.addRow(datosemp);

            }
            TablaVista.setModel(ModeloEmpleado);
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
    }
    void MostrarCliente(String muestra) {
        DefaultTableModel ModeloCliente = new DefaultTableModel();

        ModeloCliente.addColumn("ID Cliente");
        ModeloCliente.addColumn(" Nombre");
        ModeloCliente.addColumn("Direccion");
        ModeloCliente.addColumn("Telefono");

        TablaVista.setModel(ModeloCliente);
        String sql = "";
        if (muestra.equals("")) {

            sql = "SELECT * FROM cliente";
        } else {
            sql = "SELECT * FROM cliente WHERE idcliente ='" + muestra + "'";
        }
        String[] datoscli = new String[4];
        try {
            Statement st = conectar.getConnection().createStatement();
            ResultSet rs = st.executeQuery(sql);
            while (rs.next()) {
                datoscli[0] = rs.getString(1);
                datoscli[1] = rs.getString(2);
                datoscli[2] = rs.getString(3);
                datoscli[3] = rs.getString(4);

                ModeloCliente.addRow(datoscli);

            }
            TablaVista.setModel(ModeloCliente);
        } catch (SQLException ex) {
           JOptionPane.showMessageDialog(this, ex.getMessage());
        }
    }
    
    void MostrarJuguete(String juguete) {
        DefaultTableModel ModeloJuguete = new DefaultTableModel();

        ModeloJuguete.addColumn("ID juguete");
        ModeloJuguete.addColumn("Nombre ");
        ModeloJuguete.addColumn("Marca");
        ModeloJuguete.addColumn("Precio unitario");
        ModeloJuguete.addColumn("Area");
        ModeloJuguete.addColumn("cantidad de piezas");
        ModeloJuguete.addColumn("Proveedor");

        TablaVista.setModel(ModeloJuguete);
        String sql = "";
        if (juguete.equals("")) {

            sql = "SELECT * FROM juguete";
        } else {
            sql = "SELECT * FROM juguete WHERE id_juguete ='" + juguete + "'";
        }
        String[] datosclie = new String[7];
        try {
            Statement st = conectar.getConnection().createStatement();
            ResultSet rs = st.executeQuery(sql);
            while (rs.next()) {
                datosclie[0] = rs.getString(1);
                datosclie[1] = rs.getString(2);
                datosclie[2] = rs.getString(3);
                 datosclie[3] = rs.getString(4);
                  datosclie[4] = rs.getString(5);
                    datosclie[5] = rs.getString(6);
                datosclie[6] = rs.getString(7);


                ModeloJuguete.addRow(datosclie);

            }
            TablaVista.setModel(ModeloJuguete);
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
    }
    void MostrarVentas(String ventas) {
        DefaultTableModel Modeloventas = new DefaultTableModel();

        Modeloventas.addColumn("ID ventas");
        Modeloventas.addColumn(" Cantidad juguetes");
        Modeloventas.addColumn("Total");
        Modeloventas.addColumn("Fecha");
        Modeloventas.addColumn("Juguete");
        Modeloventas.addColumn("Empleado");
        Modeloventas.addColumn("Cliente nick");


        Tabla_ventas.setModel(Modeloventas);
        String sql = "";
        if (ventas.equals("")) {

            sql = "SELECT * FROM ventas";
        } else {
            sql = "SELECT * FROM ventas WHERE idventas ='" + ventas + "'";
        }
        String[] datosRenta = new String[7];
        try {
            Statement st = conectar.getConnection().createStatement();
            ResultSet rs = st.executeQuery(sql);
            while (rs.next()) {
                datosRenta[0] = rs.getString(1);
                datosRenta[1] = rs.getString(2);
                datosRenta[2] = rs.getString(3);
                datosRenta[3] = rs.getString(4);
                datosRenta[4] = rs.getString(5);
                datosRenta[5] = rs.getString(6);
                datosRenta[6] = rs.getString(7);

                Modeloventas.addRow(datosRenta);

            }
            Tabla_ventas.setModel(Modeloventas);
        } catch (SQLException ex) {
          JOptionPane.showMessageDialog(this, ex.getMessage());
        }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Ventas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Ventas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Ventas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Ventas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Ventas().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable TablaVista;
    private javax.swing.JTable Tabla_ventas;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPDevol;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTBusca;
    private javax.swing.JTextField ven1;
    private javax.swing.JTextField ven2;
    private javax.swing.JTextField ven3;
    private javax.swing.JTextField ven4;
    private javax.swing.JTextField ven5;
    private javax.swing.JTextField ven6;
    private javax.swing.JTextField ven7;
    // End of variables declaration//GEN-END:variables
}
